import 'package:flutter/material.dart';
import 'package:flutter_eve_plugin/components/ye_xiu/checkpoint/checkpoint_succ_desc.dart';
import 'package:flutter_eve_plugin/constants/font_family.dart';
import 'package:flutter_eve_plugin/constants/font_weight.dart';
import 'package:flutter_eve_plugin/model/ye_xiu/checkpoint/fight_succ.dart';
import 'package:flutter_eve_plugin/utils/image_util.dart';
import 'package:flutter_eve_plugin/utils/screen_util.dart';

class CheckpointSuccCenterWidget extends StatelessWidget {
  final FightSucc info;
  const CheckpointSuccCenterWidget({Key key, this.info}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      width: setRatio(375),
      height: setRatio(260),
      margin: EdgeInsets.only(top: setRatio(291)),
      decoration: BoxDecoration(
          image: DecorationImage(
        fit: BoxFit.fill,
        image: AssetImage(
            imageUtilYeXiu('checkpoint/icon_checkpoint_succ_reward_center@3x')),
      )),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          Padding(
            padding: EdgeInsets.only(top: setRatio(20), bottom: setRatio(15)),
            child: Image.asset(
              (info?.gradeScore?.grade ?? 0) < 30
                  ? imageUtilYeXiu(
                      'checkpoint/icon_checkpoint_succ_reward_center_title_w@3x')
                  : imageUtilYeXiu(
                      'checkpoint/icon_checkpoint_succ_reward_center_title@3x'),
              width: setRatio(120),
              height: setRatio(35),
            ),
          ),
          Container(
            width: setRatio(375),
            height: setRatio(165),
            margin: EdgeInsets.only(left: setRatio(43), right: setRatio(43)),
            child: Stack(
              children: <Widget>[
                GridView.builder(
                  gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                      crossAxisCount: 5, childAspectRatio: 50 / 75),
                  itemCount: info?.awardList?.length ?? 0,
                  itemBuilder: (context, index) {
                    var item = info?.awardList[index];
                    return Container(
                      width: setRatio(50),
                      height: setRatio(75),
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.start,
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: <Widget>[
                          Stack(
                            children: <Widget>[
                              Image.network(
                                item?.pic ?? '',
                                width: setRatio(50),
                                height: setRatio(50),
                                fit: BoxFit.fill,
                              ),
                              Positioned(
                                right: 0,
                                bottom: 0,
                                child: Container(
                                  width: setRatio(17),
                                  height: setRatio(17),
                                  decoration: BoxDecoration(
                                      color: Color(0xbF000000),
                                      borderRadius: BorderRadius.only(
                                          topLeft: Radius.circular(setRatio(2)),
                                          bottomRight:
                                              Radius.circular(setRatio(2)))),
                                  child: Center(
                                    child: Text(
                                      '${item?.count ?? 0}',
                                      style: TextStyle(
                                          decoration: TextDecoration.none,
                                          color: Color(0xFFFFFFFF),
                                          fontFamily: FontFamily.PINGFANG,
                                          fontWeight:
                                              FontWeightCustom.PF_Medium,
                                          fontSize: setTextSp(10)),
                                    ),
                                  ),
                                ),
                              )
                            ],
                          ),
                          SizedBox(
                            height: setRatio(2),
                          ),
                          Text(
                            item?.itemName ?? '',
                            maxLines: 2,
                            overflow: TextOverflow.ellipsis,
                            style: TextStyle(
                                decoration: TextDecoration.none,
                                fontFamily: FontFamily.PINGFANG,
                                fontWeight: FontWeightCustom.PF_Medium,
                                fontSize: setTextSp(10),
                                color: Color(0xFFEFF0F8)),
                          )
                        ],
                      ),
                    );
                  },
                ),
                (info?.gradeScore?.grade ?? 0) < 30
                    ? Positioned(
                        bottom: setRatio(10),
                        left: 0,
                        right: 0,
                        child: Column(children: <Widget>[
                          CheckpointSuccDescWidget(),
                          Text('多提升自己，再接再厉吧！',
                              textAlign: TextAlign.center,
                              style: TextStyle(
                                  decoration: TextDecoration.none,
                                  color: Color(0x6FFFFFFF),
                                  fontFamily: FontFamily.PINGFANG,
                                  fontWeight: FontWeightCustom.PF_Medium,
                                  fontSize: setTextSp(12)))
                        ]),
                      )
                    : Container()
              ],
            ),
          )
        ],
      ),
    );
  }
}
